import json
data ={
    "name":"张三",
    "age":30,
    "is_student":False,
    "hobbies":['读书','跑步','唱歌'],
    "address":{
        "city":"西安",
        "邮编":"726115"
    }
}
json_str = json.dumps(data,indent=2)
print(json_str)
print(type(json_str))

python_dict = json.loads(json_str)
print(python_dict["name"])
print(type(python_dict))


print('-'*50)
with open("data.json","w",encoding="utf-8") as f:
    json.dump(data,f,ensure_ascii=False) #ebsure_ascill 保证中文正常显示

with open("data.json","r",encoding="utf-8") as f:
    loaded_data = json.load(f)
    print(loaded_data["hobbies"])










